import java.util.Scanner;

public class Java004 {
    public static void main(String[] args) {
        String s = new String();
        String s1 = new String();
        Scanner sc = new Scanner(System.in);
        s = sc.nextLine();
        s1 = sc.nextLine();
        fun(s,s1);
    }
    public static void fun(String s,String s1){
        String string="";
        String flag="";
        int j=0,z;
        for(int i=0;i<s.length();i++) {
            string="";
            for(j=0;j<s1.length();j++){
                z=i;
                while (z < s.length() && j < s1.length() && s.charAt(z) == s1.charAt(j)) {
                    string += s.charAt(z);
                    z++;
                    j++;
                }
                if(string.length()>flag.length()){
                flag=string;
            }

        }}
        System.out.println("Longest string:"+flag);
    }
}
//相同的最长的字符串
